﻿using MediatR;
using Microsoft.AspNetCore.Mvc.Routing;
using System.CJL.API.Application.Command.StorageCommand;
using System.CJL.Domain;
using System.CJL.Infrstructre.Interface;

namespace System.CJL.API.Application.CommandHanlder.StorageCommandHandler
{
    public class StoragesPurchaseNumberShowCommandHandler:IRequestHandler<StoragesPurchaseNumberShowCommand, List<Storage>>
    {
        IStorageRepository _repository;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="repository"></param>
        public StoragesPurchaseNumberShowCommandHandler(IStorageRepository repository)
        {
            _repository = repository;
        }

        public async Task<List<Storage>> Handle(StoragesPurchaseNumberShowCommand request, CancellationToken cancellationToken)
        {
          var count = (from Stor in  await _repository.GetAll() where Stor.DetailsNumbering== request.ProcuredNumber select Stor);
            return count.ToList()  ;
        }
    }
}
